#include <string.h>
#include <stdlib.h>
#include "PkgBuf.h"

CPkgBuf::CPkgBuf()
{
    m_pBuf = nullptr;
    m_nSize = 0;
}

CPkgBuf::~CPkgBuf()
{
    Destroy();
}

bool CPkgBuf::Init(uint32_t nMax)
{
    m_pBuf = (uint8_t *)malloc(nMax);

    if (nullptr != m_pBuf)
        memset(m_pBuf, 0, nMax);

    return (nullptr != m_pBuf);
}

void CPkgBuf::Destroy()
{
    if (nullptr != m_pBuf)
    {
        free(m_pBuf);
        m_pBuf = nullptr;
    }
}